package com.edu.lawdoc.api.controller;

import com.edu.lawdoc.api.controller.assistor.Result;
import com.edu.lawdoc.errors.Errors;
import com.edu.lawdoc.generator.db.output.model.DemoOptions;
import com.edu.lawdoc.generator.field.output.Column;
import com.edu.lawdoc.i18n.I18nDelegate;
import com.edu.lawdoc.srv.Srv;
import com.jfinal.core.Controller;

import java.util.List;

public class DemoController extends Controller {


    public void hello() {
        renderText("Hello World");
    }

    public void jsp() {
        renderJsp("index.jsp");
    }

    public void i18n() {
        renderText(I18nDelegate.get(Errors.BUSINESS_IS_NOT_AFFECTED));
    }

    public void call500() {
        renderError(500);
    }

    public void query() {
        String optionName = getPara(Column.DEMO_OPTIONS.OPTION_NAME);
        List<DemoOptions> list = DemoOptions.dao.find("select * from demo_options where option_name = ?", optionName);
        Result.success(this, list);
    }

    public void update() {
        Srv.demoSrv.update(1, 1, "newValue");
        Result.success(this);
    }
}
